home *** CD-ROM | disk | FTP | other *** search
/ Adobe Graphics & Publishing SDK 1996 December / Adobe Graphics & Publishing SDK 1996 December.iso / pc / pr42sdk / examples / projects / export / ex-vxx.c next >
Encoding:
C/C++ Source or Header  |  1995-10-07  |  4.0 KB  |  164 lines

  1. //========================================================================================
  2. //
  3. // Ex-vxx.c - Video export plugin for Premiere.
  4. //
  5. // Part of the Adobe Premiere 4.2 Plug-in Developer's Toolkit.
  6. //
  7. // Copyright 1996, Adobe Systems Incorporated, all rights reserved worldwide.
  8. //
  9. // Written by Nick Schlott.
  10. //
  11. // This plugin exports from a source clip to a mythical format
  12. // called .VXX. This file format consists of a short header, 
  13. // followed by n frames of 32bpp RGB frames.
  14. //
  15. // 1.00     1/25/94 njs
  16. // 1.02     1/10/96 ba        Updated for Premiere 4.2 and MSVC++ 2.2 & 4.0.
  17. //
  18. //----------------------------------------------------------------------------------------
  19.  
  20. #include <windows.h>
  21.  
  22. #include "Compat.h"
  23. #include "Premiere.h"
  24.  
  25.  
  26. char *vxxHeader = "VXX File Header ->\0";
  27. char *vxxBody   = "VXX Body ->\0";
  28.  
  29. HINSTANCE    ghInst;
  30.  
  31. BOOL WINAPI DllMain (HINSTANCE hDLL, DWORD dwReason, LPVOID lpReserved)
  32. {
  33.     switch (dwReason)
  34.     {
  35.         case DLL_PROCESS_ATTACH:
  36.             ghInst = hDLL;
  37.             break;
  38.  
  39.         case DLL_THREAD_ATTACH:
  40.             break;
  41.  
  42.         case DLL_THREAD_DETACH:
  43.             break;
  44.  
  45.         case DLL_PROCESS_DETACH:
  46.             break;
  47.     }
  48.     return(TRUE);
  49. }
  50.  
  51.  
  52. //--------------------------------------------------------------------------
  53. // prompt for an output file
  54.  
  55. int PutFile (char *name)
  56. {
  57.     OPENFILENAME    ofn;
  58.  
  59.     ofn.lStructSize = sizeof(OPENFILENAME);
  60.     ofn.lpstrFilter = "*.vxx";
  61.     ofn.hwndOwner = GetLastActivePopup(GetMainWnd());
  62.     ofn.hInstance = ghInst;
  63.     ofn.nFilterIndex = 0;
  64.     ofn.lpstrFileTitle = NULL;
  65.     ofn.nMaxFileTitle = 31;
  66.     name[0] = 0;
  67.     ofn.lpstrFile = (LPSTR)name;
  68.     ofn.nMaxFile = _MAX_PATH;
  69.     ofn.lpstrInitialDir = NULL;
  70.     ofn.Flags = OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY;
  71.     ofn.lpstrCustomFilter = NULL;
  72.     ofn.nMaxCustFilter = 0;
  73.     ofn.nFileOffset = ofn.nFileExtension = 0;
  74.     ofn.lpstrDefExt = "vxx";
  75.     ofn.lCustData = 0;
  76.     ofn.lpfnHook = NULL;
  77.     ofn.lpTemplateName = NULL;
  78.     ofn.lpstrTitle=NULL;
  79.     ofn.lpstrTitle=NULL;
  80.     return GetSaveFileName(&ofn);
  81. }
  82.  
  83.  
  84. //--------------------------------------------------------------------------
  85. // entry point
  86.  
  87. int PRMEXPORT xExport (short selector, DataExportHandle theData)
  88. {
  89.     short                result = 0, err;
  90.     long                first, last, current, outsize, numframes;
  91.     GetVidCallBack        getvid;
  92.     PWorldID            thePort;
  93.     PPixHand            pix;
  94.     Ptr                    srcbase;
  95.     HFILE                ref;
  96.     char                fname[_MAX_PATH];
  97.     OFSTRUCT            of;
  98.     RECT                box;
  99.  
  100.     if (selector == edExecute)
  101.     {
  102.         result = 1;
  103.         getvid = (*theData)->getVideo;    // get the frame callback function
  104.  
  105.     // prompt for file name
  106.  
  107.         if(PutFile(fname))
  108.         {
  109.         // create the output file
  110.  
  111.             ref = OpenFile(fname, &of, OF_CREATE | OF_READWRITE);
  112.             if (ref != HFILE_ERROR)
  113.             {
  114.  
  115.             // calc the number of frames
  116.  
  117.                 first = (*theData)->markers[0];            // get the IN point
  118.                 last = (*theData)->markers[1];            // get the OUT point
  119.                 numframes = last-first;
  120.  
  121.             // make a new pixmap to image RGB data to.
  122.             // get the thePort's pixmap 
  123.  
  124.                 box = (*theData)->bounds;
  125.                 err = NewPWorld(&thePort, &box);
  126.                 if(!err)
  127.                 {
  128.                     pix = GetPWorldBits(thePort);
  129.  
  130.                 // write the header
  131.  
  132.                     _hwrite(ref, vxxHeader, strlen(vxxHeader));
  133.                     _hwrite(ref, &(char)numframes, sizeof(long));
  134.                     _hwrite(ref, &(char)box.left, sizeof(long));
  135.                     _hwrite(ref, &(char)box.top, sizeof(long));
  136.                     _hwrite(ref, &(char)box.right, sizeof(long));
  137.                     _hwrite(ref, &(char)box.bottom, sizeof(long));
  138.                     _hwrite(ref, &(char)(*pix)->rowbytes, sizeof((*pix)->rowbytes));
  139.                     _hwrite(ref, vxxBody, strlen(vxxBody));
  140.  
  141.                 // Loop until we're done exporting
  142.  
  143.                     for (current = first; current < last ; current++)
  144.                     {
  145.                         (getvid)(current, thePort, &box, (*theData)->privateData);
  146.                         srcbase = (*pix)->pix;
  147.                         outsize = (*pix)->rowbytes * (box.bottom - box.top);
  148.                         _hwrite(ref, srcbase, outsize);
  149.                     }
  150.                     _lclose(ref);
  151.  
  152.                 // nuke the port
  153.  
  154.                     if (thePort) 
  155.                         DisposePWorld(thePort);
  156.  
  157.                     result = 0;
  158.                 }
  159.             }
  160.         }
  161.     }
  162.     return (result);
  163. }
  164.